/************************************************************************
 *
 * math.h
 *
 * (c) Copyright 1996-2006 Analog Devices, Inc.  All rights reserved.
 * $Revision: 1.1.20.1 $
 ************************************************************************/

#pragma once
#ifndef __NO_BUILTIN
#pragma system_header /* math.h */
#endif

#ifndef __MATH_DEFINED
#define __MATH_DEFINED

/* Analog extensions to math.h are located in
 * a platform specific include file.
 * Use the compile option -D__NO_ANSI_EXTENSIONS__
 * to exclude any such extensions.
 */
#if !defined( __NO_ANSI_EXTENSIONS__ )
#if defined ( __ADSPTS__ )

#include <math_ts.h>

#endif    /* __ADSPTS__             */
#endif    /* __NO_ANSI_EXTENSIONS__ */


#ifndef HUGE_VAL
  #ifdef __DOUBLES_ARE_FLOATS__
    #define HUGE_VAL    3.402823466e+38F
  #else
    #define HUGE_VAL    1.797693134862315708e+308
  #endif
#endif /* HUGE_VAL */


/* ==== BUILTIN versions are available for fabsf(), fabs() and fabsd() ==== */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef __NO_BUILTIN   /* Built-ins are defined */
  float         fabsf (float);
  long double   fabsd (long double);

#ifndef __cplusplus
  double        fabs (double);

#ifdef __DOUBLES_ARE_FLOATS__
#define fabs    fabsf
#else
#define fabs    fabsd
#endif

#endif   /* __cplusplus  */

  #define  fabsf  __builtin_fabsf
  #define  fabsd  __builtin_fabs

#else    /* __NO_BUILTIN */
#ifdef __cplusplus
extern "C" {
#endif
                    _Pragma("linkage_name __fabsf")
  float         fabsf (float);
                    _Pragma("linkage_name __fabsd")
  long double   fabsd (long double);

#ifdef __cplusplus
}        /* extern "C"  */
#else    /* __cplusplus */
#ifdef __DOUBLES_ARE_FLOATS__
                    _Pragma("linkage_name __fabsf")
#else
                    _Pragma("linkage_name __fabsd")
#endif
  double        fabs (double);
#endif   /* __cplusplus  */

#endif   /* __NO_BUILTIN */


#ifdef __cplusplus
}
extern "C++" {

  #pragma always_inline
  __inline  float  fabs(float _a)
  {
      return  fabsf(_a);
  }
  #pragma always_inline
  __inline  long double  fabs(long double _a)
  {
      return  fabsd(_a);
  }
  #pragma always_inline
  __inline  double  fabs(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  fabsf(_a);
#else
      return  fabsd(_a);
#endif
  }

}        /* extern "C++" */
#endif   /* __cplusplus  */


/* ========== Double Precision (double word) Functions ========== */

#ifdef __cplusplus
extern "C" {
#endif

                    _Pragma("linkage_name __acosd")
  long double   acosd (long double);
                    _Pragma("linkage_name __asind")
  long double   asind (long double);
                    _Pragma("linkage_name __atand")
  long double   atand (long double);
                    _Pragma("linkage_name __atan2d")
  long double   atan2d (long double, long double);
                    _Pragma("linkage_name __ceild")
  long double   ceild (long double);
                    _Pragma("linkage_name __cosd")
  long double   cosd (long double);
                    _Pragma("linkage_name __coshd")
  long double   coshd (long double);
                    _Pragma("linkage_name __expd")
  long double   expd (long double);
                    _Pragma("linkage_name __floord")
  long double   floord (long double);
                    _Pragma("linkage_name __fmodd")
  long double   fmodd (long double, long double);
                    _Pragma("linkage_name __frexpd")
  long double   frexpd (long double, int *);
                    _Pragma("linkage_name __ldexpd")
  long double   ldexpd (long double, int);
                    _Pragma("linkage_name __logd")
  long double   logd (long double);
                    _Pragma("linkage_name __log10d")
  long double   log10d (long double);
                    _Pragma("linkage_name __modfd")
  long double   modfd (long double, long double *);
                    _Pragma("linkage_name __powd")
  long double   powd (long double, long double);
                    _Pragma("linkage_name __sind")
  long double   sind (long double);
                    _Pragma("linkage_name __sinhd")
  long double   sinhd (long double);
                    _Pragma("linkage_name __sqrtd")
  long double   sqrtd (long double);
                    _Pragma("linkage_name __tand")
  long double   tand (long double);
                    _Pragma("linkage_name __tanhd")
  long double   tanhd (long double);


/* ========== Single Precision Functions ========== */

                    _Pragma("linkage_name __acosf")
  float   acosf(float);
                    _Pragma("linkage_name __asinf")
  float   asinf(float);
                    _Pragma("linkage_name __atan2f")
  float   atan2f(float, float);
                    _Pragma("linkage_name __atanf")
  float   atanf(float);
                    _Pragma("linkage_name __ceilf")
  float   ceilf(float);
                    _Pragma("linkage_name __cosf")
  float   cosf(float);
                    _Pragma("linkage_name __coshf")
  float   coshf(float);
                    _Pragma("linkage_name __expf")
  float   expf(float);
                    _Pragma("linkage_name __floorf")
  float   floorf(float);
                    _Pragma("linkage_name __fmodf")
  float   fmodf(float, float);
                    _Pragma("linkage_name __frexpf")
  float   frexpf(float, int *);
                    _Pragma("linkage_name __ldexpf")
  float   ldexpf(float, int);
                    _Pragma("linkage_name __log10f")
  float   log10f(float);
                    _Pragma("linkage_name __logf")
  float   logf(float);
                    _Pragma("linkage_name __modff")
  float   modff(float, float *);
                    _Pragma("linkage_name __powf")
  float   powf(float, float);
                    _Pragma("linkage_name __sinf")
  float   sinf(float);
                    _Pragma("linkage_name __sinhf")
  float   sinhf(float);
                    _Pragma("linkage_name __sqrtf")
  float   sqrtf(float);
                    _Pragma("linkage_name __tanf")
  float   tanf(float);
                    _Pragma("linkage_name __tanhf")
  float   tanhf(float);


#ifdef __cplusplus
}
#endif


/* ========== Standard Math (Double) Functions ========== */

#if !defined(__cplusplus)

#ifdef __DOUBLES_ARE_FLOATS__
/* ==========    when double == float          ========== */
/* ==========     double size == 32            ========== */

                    _Pragma("linkage_name __acosf")
  double   acos (double);
                    _Pragma("linkage_name __asinf")
  double   asin (double);
                    _Pragma("linkage_name __atanf")
  double   atan (double);
                    _Pragma("linkage_name __atan2f")
  double   atan2 (double, double);
                    _Pragma("linkage_name __ceilf")
  double   ceil (double);
                    _Pragma("linkage_name __cosf")
  double   cos (double);
                    _Pragma("linkage_name __coshf")
  double   cosh (double);
                    _Pragma("linkage_name __expf")
  double   exp (double);
                    _Pragma("linkage_name __floorf")
  double   floor (double);
                    _Pragma("linkage_name __fmodf")
  double   fmod (double, double);
                    _Pragma("linkage_name __frexpf")
  double   frexp (double, int *);
                    _Pragma("linkage_name __ldexpf")
  double   ldexp (double, int);
                    _Pragma("linkage_name __logf")
  double   log (double);
                    _Pragma("linkage_name __log10f")
  double   log10 (double);
                    _Pragma("linkage_name __modff")
  double   modf (double, double *);
                    _Pragma("linkage_name __powf")
  double   pow (double, double);
                    _Pragma("linkage_name __sinf")
  double   sin (double);
                    _Pragma("linkage_name __sinhf")
  double   sinh (double);
                    _Pragma("linkage_name __sqrtf")
  double   sqrt (double);
                    _Pragma("linkage_name __tanf")
  double   tan (double);
                    _Pragma("linkage_name __tanhf")
  double   tanh (double);

#else
 /* ==========   when double == long double    ========== */
 /* ==========    double size == 64            ========== */

                    _Pragma("linkage_name __acosd")
  double   acos (double);
                    _Pragma("linkage_name __asind")
  double   asin (double);
                    _Pragma("linkage_name __atand")
  double   atan (double);
                    _Pragma("linkage_name __atan2d")
  double   atan2 (double, double);
                    _Pragma("linkage_name __ceild")
  double   ceil (double);
                    _Pragma("linkage_name __cosd")
  double   cos (double);
                    _Pragma("linkage_name __coshd")
  double   cosh (double);
                    _Pragma("linkage_name __expd")
  double   exp (double);
                    _Pragma("linkage_name __floord")
  double   floor (double);
                    _Pragma("linkage_name __fmodd")
  double   fmod (double, double);
                    _Pragma("linkage_name __frexpd")
  double   frexp (double, int *);
                    _Pragma("linkage_name __ldexpd")
  double   ldexp (double, int);
                    _Pragma("linkage_name __logd")
  double   log (double);
                    _Pragma("linkage_name __log10d")
  double   log10 (double);
                    _Pragma("linkage_name __modfd")
  double   modf (double, double *);
                    _Pragma("linkage_name __powd")
  double   pow (double, double);
                    _Pragma("linkage_name __sind")
  double   sin (double);
                    _Pragma("linkage_name __sinhd")
  double   sinh (double);
                    _Pragma("linkage_name __sqrtd")
  double   sqrt (double);
                    _Pragma("linkage_name __tand")
  double   tan (double);
                    _Pragma("linkage_name __tanhd")
  double   tanh (double);

#endif /* __DOUBLES_ARE_FLOATS__ */
#else  /* !defined(__cplusplus)  */
extern "C++" {

  #pragma always_inline
  __inline  float  acos(float _a)
  {
      return  acosf(_a);
  }
  #pragma always_inline
  __inline  long double  acos(long double _a)
  {
      return  acosd(_a);
  }
  #pragma always_inline
  __inline  double  acos(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  acosf(_a);
#else
      return  acosd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  asin(float _a)
  {
      return  asinf(_a);
  }
  #pragma always_inline
  __inline  long double  asin(long double _a)
  {
      return  asind(_a);
  }
  #pragma always_inline
  __inline  double  asin(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  asinf(_a);
#else
      return  asind(_a);
#endif
  }

  #pragma always_inline
  __inline  float  atan(float _a)
  {
      return  atanf(_a);
  }
  #pragma always_inline
  __inline  long double  atan(long double _a)
  {
      return  atand(_a);
  }
  #pragma always_inline
  __inline  double  atan(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  atanf(_a);
#else
      return  atand(_a);
#endif
  }

  #pragma always_inline
  __inline  float  atan2(float _a, float _b)
  {
      return  atan2f(_a, _b);
  }
  #pragma always_inline
  __inline  long double  atan2(long double _a, long double _b)
  {
      return  atan2d(_a, _b);
  }
  #pragma always_inline
  __inline  double  atan2(double _a, double _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  atan2f(_a, _b);
#else
      return  atan2d(_a, _b);
#endif
  }

  #pragma always_inline
  __inline  float  ceil(float _a)
  {
      return  ceilf(_a);
  }
  #pragma always_inline
  __inline  long double  ceil(long double _a)
  {
      return  ceild(_a);
  }
  #pragma always_inline
  __inline  double  ceil(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  ceilf(_a);
#else
      return  ceild(_a);
#endif
  }

  #pragma always_inline
  __inline  float  cos(float _a)
  {
      return  cosf(_a);
  }
  #pragma always_inline
  __inline  long double  cos(long double _a)
  {
      return  cosd(_a);
  }
  #pragma always_inline
  __inline  double  cos(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  cosf(_a);
#else
      return  cosd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  cosh(float _a)
  {
      return  coshf(_a);
  }
  #pragma always_inline
  __inline  long double  cosh(long double _a)
  {
      return  coshd(_a);
  }
  #pragma always_inline
  __inline  double  cosh(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  coshf(_a);
#else
      return  coshd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  exp(float _a)
  {
      return  expf(_a);
  }
  #pragma always_inline
  __inline  long double  exp(long double _a)
  {
      return  expd(_a);
  }
  #pragma always_inline
  __inline  double  exp(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  expf(_a);
#else
      return  expd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  floor(float _a)
  {
      return  floorf(_a);
  }
  #pragma always_inline
  __inline  long double  floor(long double _a)
  {
      return  floord(_a);
  }
  #pragma always_inline
  __inline  double  floor(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  floorf(_a);
#else
      return  floord(_a);
#endif
  }

  #pragma always_inline
  __inline  float  fmod(float _a, float _b)
  {
      return  fmodf(_a, _b);
  }
  #pragma always_inline
  __inline  long double  fmod(long double _a, long double _b)
  {
      return  fmodd(_a, _b);
  }
  #pragma always_inline
  __inline  double  fmod(double _a, double _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  fmodf(_a, _b);
#else
      return  fmodd(_a, _b);
#endif
  }

  #pragma always_inline
  __inline  float  frexp(float _a, int* _b)
  {
      return  frexpf(_a, _b);
  }
  #pragma always_inline
  __inline  long double  frexp(long double _a, int* _b)
  {
      return  frexpd(_a, _b);
  }
  #pragma always_inline
  __inline  double  frexp(double _a, int* _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  frexpf(_a, _b);
#else
      return  frexpd(_a, _b);
#endif
  }

  #pragma always_inline
  __inline  float  ldexp(float _a, int _b)
  {
      return  ldexpf(_a, _b);
  }
  #pragma always_inline
  __inline  long double  ldexp(long double _a, int _b)
  {
      return  ldexpd(_a, _b);
  }
  #pragma always_inline
  __inline  double  ldexp(double _a, int _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  ldexpf(_a, _b);
#else
      return  ldexpd(_a, _b);
#endif
  }

  #pragma always_inline
  __inline  float  log(float _a)
  {
      return  logf(_a);
  }
  #pragma always_inline
  __inline  long double  log(long double _a)
  {
      return  logd(_a);
  }
  #pragma always_inline
  __inline  double  log(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  logf(_a);
#else
      return  logd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  log10(float _a)
  {
      return  log10f(_a);
  }
  #pragma always_inline
  __inline  long double  log10(long double _a)
  {
      return  log10d(_a);
  }
  #pragma always_inline
  __inline  double  log10(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  log10f(_a);
#else
      return  log10d(_a);
#endif
  }

  #pragma always_inline
  __inline  float  modf(float _a, float* _b)
  {
      return  modff(_a, _b);
  }
  #pragma always_inline
  __inline  long double  modf(long double _a, long double* _b)
  {
      return  modfd(_a, _b);
  }
  #pragma always_inline
  __inline  double  modf(double _a, double* _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  modff(_a, (float *) _b);
#else
      return  modfd(_a, (long double*) _b);
#endif
  }

  #pragma always_inline
  __inline  float  pow(float _a, float _b)
  {
      return  powf(_a, _b);
  }
  #pragma always_inline
  __inline  long double  pow(long double _a, long double _b)
  {
      return  powd(_a, _b);
  }
  #pragma always_inline
  __inline  double  pow(double _a, double _b)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  powf(_a, _b);
#else
      return  powd(_a, _b);
#endif
  }

  #pragma always_inline
  __inline  float  sin(float _a)
  {
      return  sinf(_a);
  }
  #pragma always_inline
  __inline  long double  sin(long double _a)
  {
      return  sind(_a);
  }
  #pragma always_inline
  __inline  double  sin(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  sinf(_a);
#else
      return  sind(_a);
#endif
  }

  #pragma always_inline
  __inline  float  sinh(float _a)
  {
      return  sinhf(_a);
  }
  #pragma always_inline
  __inline  long double  sinh(long double _a)
  {
      return  sinhd(_a);
  }
  #pragma always_inline
  __inline  double  sinh(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  sinhf(_a);
#else
      return  sinhd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  sqrt(float _a)
  {
      return  sqrtf(_a);
  }
  #pragma always_inline
  __inline  long double  sqrt(long double _a)
  {
      return  sqrtd(_a);
  }
  #pragma always_inline
  __inline  double  sqrt(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  sqrtf(_a);
#else
      return  sqrtd(_a);
#endif
  }

  #pragma always_inline
  __inline  float  tan(float _a)
  {
      return  tanf(_a);
  }
  #pragma always_inline
  __inline  long double  tan(long double _a)
  {
      return  tand(_a);
  }
  #pragma always_inline
  __inline  double  tan(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  tanf(_a);
#else
      return  tand(_a);
#endif
  }

  #pragma always_inline
  __inline  float  tanh(float _a)
  {
      return  tanhf(_a);
  }
  #pragma always_inline
  __inline  long double  tanh(long double _a)
  {
      return  tanhd(_a);
  }
  #pragma always_inline
  __inline  double  tanh(double _a)
  {
#if defined(__DOUBLES_ARE_FLOATS__)
      return  tanhf(_a);
#else
      return  tanhd(_a);
#endif
  }

}        /* extern "C++"           */
#endif   /* !defined(__cplusplus)  */

#endif   /* __MATH_DEFINED         */


